#include <jni.h>
#include <pthread.h>

extern "C" {
#ifdef __cplusplus
#define __STDC_CONSTANT_MACROS
#ifdef _STDINT_H
#undef _STDINT_H
#endif
#include <stdint.h>
#endif
}

#ifdef __cplusplus
extern "C" {
#endif

#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <libavdevice/avdevice.h>

//视频录制的调用,实现初始化
JNIEXPORT jlong JNICALL
Java_com_hxrk_jni_Mp4v2Native_mp4init(JNIEnv *env, jobject thiz, jint id, jstring title, jint w,
                                      jint h, jint timeScale, jint frameRate, jint A_timeScale,
                                      jint A_sampleDuration, jint debug);

JNIEXPORT jlong JNICALL Java_com_hxrk_jni_Mp4v2Native_getmipiproc(JNIEnv *env, jobject thiz);

//JNIEXPORT void JNICALL Java_com_hxrk_jni_Mp4v2Native_testException1(JNIEnv* env,jobject thiz);
JNIEXPORT void JNICALL
Java_com_hxrk_jni_Mp4v2Native_mipiSendH264Data(JNIEnv *env, jobject thiz,jint id, jbyteArray buf, jint size, jint Frametype, jint streamtype);
//添加视频帧的方法
JNIEXPORT jint JNICALL
Java_com_hxrk_jni_Mp4v2Native_mp4packVideo(JNIEnv *env, jobject thiz, jint id, jlong pdata,
                                           jint size);

JNIEXPORT jint JNICALL
Java_com_hxrk_jni_Mp4v2Native_mp4packVideo2(JNIEnv *env, jobject thiz, jint id, jbyteArray data,
                                            jint size);
//子码流
JNIEXPORT jint JNICALL
Java_com_hxrk_jni_Mp4v2Native_mp4packVideo2sub(JNIEnv *env, jobject thiz, jint id, jbyteArray data,
                                               jint size);

//添加音频帧的方法
JNIEXPORT jint JNICALL
Java_com_hxrk_jni_Mp4v2Native_mp4packAudio2(JNIEnv *env, jobject thiz, jint id, jbyteArray data,
                                            jint size);

JNIEXPORT jint JNICALL
Java_com_hxrk_jni_Mp4v2Native_mp4packAudio(JNIEnv *env, jobject thiz, jint id, jlong pdata,
                                           jint size);

//视频录制结束调用
JNIEXPORT jint JNICALL Java_com_hxrk_jni_Mp4v2Native_mp4close(JNIEnv *env, jobject thiz, jint id);

JNIEXPORT jint JNICALL Java_com_hxrk_jni_Mp4v2Native_GetMp4v2Version(JNIEnv *env, jobject thiz);

JNIEXPORT jint JNICALL
Java_com_hxrk_jni_Mp4v2Native_RTPstart(JNIEnv *env, jobject thiz, jint id, jstring ip, jint port,
                                       jint udpport, jint datatype, jint streamtype, jint nettype,
                                       jint PTType, jint maxpk, jbyteArray cmd1209,jint is1078);

JNIEXPORT jint JNICALL
Java_com_hxrk_jni_Mp4v2Native_RTPctrl(JNIEnv *env, jobject thiz, jint id, jint KZZL, jint YSPLX,
                                      jint MLLX);

JNIEXPORT jint JNICALL
Java_com_hxrk_jni_Mp4v2Native_RTPfilestart(JNIEnv *env, jobject thiz, jint id, jstring ip,
                                           jint port, jint udpport, jint datatype, jint KJKT,
                                           jint streamtype, jint nettype, jint PTType, jint maxpk,
                                           jstring files, jbyteArray cmd1209,jint is1078);

JNIEXPORT jint JNICALL
Java_com_hxrk_jni_Mp4v2Native_RTPfilectrl(JNIEnv *env, jobject thiz, jint id, jint CSKZ,
                                          jint KJKT_BS, jstring TDHFWZ);

JNIEXPORT jint JNICALL
Java_com_hxrk_jni_Mp4v2Native_jpeginit(JNIEnv *env, jobject thiz, jint id, jint w, jint h);

JNIEXPORT jint JNICALL
Java_com_hxrk_jni_Mp4v2Native_jpegsave(JNIEnv *env, jobject thiz, jint id, jint workid,
                                       jstring filename);

JNIEXPORT void JNICALL Java_com_hxrk_jni_Mp4v2Native_jpegclose(JNIEnv *env, jobject thiz, jint id);

JNIEXPORT jint JNICALL Java_com_hxrk_jni_Mp4v2Native_videoopen_f(JNIEnv *env, jobject thiz);

JNIEXPORT jint JNICALL
Java_com_hxrk_jni_Mp4v2Native_videoread_f(JNIEnv *env, jobject thiz, jint id);

JNIEXPORT jint JNICALL Java_com_hxrk_jni_Mp4v2Native_videoclose_f(JNIEnv *env, jobject thiz, jint id);

JNIEXPORT jint JNICALL
Java_com_hxrk_jni_Mp4v2Native_videoopen(JNIEnv *env, jobject thiz, jint w, jint h);

JNIEXPORT jint JNICALL
Java_com_hxrk_jni_Mp4v2Native_videoread(JNIEnv *env, jobject thiz, jint id, jobject bitmap1,
                                        jbyteArray yuvdata, jbyteArray subyuvdata,
                                        jbooleanArray rtpstatus);

JNIEXPORT jint JNICALL
Java_com_hxrk_jni_Mp4v2Native_videowatermark(JNIEnv *env, jobject thiz, jint id, jint group,
                                             jstring info);

JNIEXPORT jint JNICALL Java_com_hxrk_jni_Mp4v2Native_videoclose(JNIEnv *env, jobject thiz, jint id);

JNIEXPORT jint JNICALL
Java_com_hxrk_jni_Mp4v2Native_videowatermarkex(JNIEnv *env, jobject thiz, jint id, jint index,
                                               jstring params, jint x, jint y, jint s);

void closeVideoLoop();


JNIEXPORT void JNICALL
Java_com_hxrk_jni_Mp4v2Native_setNativeDrawFrame(JNIEnv *env, jobject thiz, jlong pf);

JNIEXPORT void JNICALL
Java_com_hxrk_jni_Mp4v2Native_faceStart(JNIEnv *env, jobject thiz, jint status, jint bFlag);

JNIEXPORT void JNICALL
Java_com_hxrk_jni_Mp4v2Native_setNativeGetFaceNumber(JNIEnv *env, jobject thiz, jlong pf);

JNIEXPORT void JNICALL
Java_com_hxrk_jni_Mp4v2Native_setParams(JNIEnv *env, jobject thiz,jint cameraid, jint channelNumber,jint sim_1,jint sim_2,
                                        jint sim_3,jint sim_4,jint sim_5,jint sim_6);

#ifdef __cplusplus
}
#endif
